#define DEBUG
#include <cstdio>
#include <cstring>

using namespace std;

int max(int a, int b) {
	return a>b ? a : b;
}

const int maxn=500, maxk=100;

int main() {
#ifdef DEBUG
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
#endif

	static char s[maxn+2];
	int n, k;
	scanf("%d %d", &n, &k);
	scanf("%s", s+1);

	static int f[maxn+1][maxk+2][maxk+2];
	memset(f, 128, sizeof(f));
	f[1][k][k] = f[0][k][k] = 0;
	int ans=0;
	for (int i=2; i<=n; i++) {
		for (int x=k; x>=0; x--) {
			for (int y=k; y>=0; y--) {
				f[i][x][y] = f[i-1][x][y];
				if (s[i-1]=='j' && s[i]=='z') {
					f[i][x][y] = max(f[i][x][y], f[i-2][x][y]+1);
				}
				if (s[i-1]=='z' && s[i]=='j' && x+1<=k && y+1<=k) {
					f[i][x][y] = max(f[i][x][y], f[i-2][x+1][y+1]+1);
				}
				if (s[i-1]=='j' && s[i]=='j' && x+1<=k) {
					f[i][x][y] = max(f[i][x][y], f[i-2][x+1][y]+1);
				}
				if (s[i-1]=='z' && s[i]=='z' && y+1<=k) {
					f[i][x][y] = max(f[i][x][y], f[i-2][x][y+1]+1);
				}
				if (x==y) {
					ans = max(ans, f[i][x][y]);
				}
			}
		}
	}
	printf("%d", ans);

	fclose(stdin);
	fclose(stdout);
	return 0;
}
